package com.jinbiao.annotion2;

import java.lang.reflect.Field;

import javax.activation.FileDataSource;
import javax.swing.plaf.synth.SynthSeparatorUI;

import com.sun.net.ssl.internal.ssl.Provider;



/**
 * 
 * 注解处理器
 * 包含了注解的处理逻辑代码
 * @author EX_WLJR_ZHUANGJB
 *
 */
public class FruitUtil {

	public static void getFruitInfo(Class<?> cla) {
		String strFruitName ="水果名称";
		String strFruitColor = "水果的颜色";
		String strFruitProvider="供应商信息";
		
		 Field[] fields =cla.getDeclaredFields();
		
		 //检查带 FruitName 的注解
		 for (Field field : fields) {
			if(field.isAnnotationPresent(FruitName.class)) {
				FruitName fruitName = field.getAnnotation(FruitName.class);
				strFruitName = strFruitName+fruitName.value();
				System.out.println(strFruitName);
			}else if( field.isAnnotationPresent(FruitColor.class)) {
				FruitColor color = field.getAnnotation(FruitColor.class);
				strFruitColor = strFruitColor+color.fruitColor().toString();
				System.out.println(strFruitColor);
			}else if (field.isAnnotationPresent(FruitProvider.class)) {
				FruitProvider fruitProvider = field.getAnnotation(FruitProvider.class);
				strFruitProvider ="供应商编号："+fruitProvider.id()+"供应商名称:"+fruitProvider.name().toString()
						+"供应商地址:"+fruitProvider.address().toString();
				System.out.println(strFruitProvider);
			}
		}
	
		
	}
	
	
}
